<!-- 工资申领 -->
<template>
	<view class="p-3">
		<scroll-view scroll-y="true" @scrolltolower="loadMore" v-if="dataList.length>0" class="scroll-block">
			<view class="bt-block mb-3" v-for="i,idx in dataList" :key="idx" @click="gotoDetail(i)">
				<bg-cell>
					<template>
						<view>
							<bg-desc label="申请人" :value="i.userName"></bg-desc>
							<bg-desc label="合计金额" :value="i.salaryAmount"></bg-desc>
							<bg-desc label="项目名称" :value="i.projectName"></bg-desc>
							<bg-desc label="提交时间" :value="i.createTime"></bg-desc>
							<bg-desc label="审核状态" :value="i.auditStatus==1?'待审批':i.auditStatus==2?'审批通过':'审批不通过'"></bg-desc>
						</view>
					</template>
				</bg-cell>
				<bg-cell :border="false" :showArrow="true">
					<text v-if="i.status==1" style="color:#1DBF5C">发送成功</text>
				</bg-cell>
			</view>
		</scroll-view>
		<u-empty v-else></u-empty>
	</view>
</template>

<script>
	import { salaryList } from '../../../api/salary'
	export default {
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url:"/pages/common/sms/sms?title=工资申领&btnTitle=去申领&targetUrl=/pages/salary/salary/salary"
			})
		},
		data() {
			return {
				dataList:[],
				params:{
					pageSize:10,
					pageNum:1
				},
				total:0,
			}
		},
		mounted() {
			this.getData()
			uni.$on("refresh-page", ()=>{
				this.dataList = []
				this.params.pageNum  =1
				this.getData()
			})
		},
		methods: {
			getData(){
				salaryList().then(res=>{
					this.dataList = [...this.dataList, ...res.data.rows]
					this.total = res.data.total
				})
			},
			loadMore(){
				if(this.dataList.length < this.total){
					this.params.pageNum += 1
					this.getData()
				}
			},
			gotoDetail(i){
				uni.navigateTo({
					url:"/pages/salary/salary/detail?id="+i.id
				})
			}
		}
	}
</script>

<style>

</style>
